namespace Akso.Migrations
{
    using System;
    using System.Collections.Generic;
    using System.Data.Entity.Infrastructure.Annotations;
    using System.Data.Entity.Migrations;
    
    public partial class Add_BSC_PSS_EDU : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Basic_Classrooms",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        TenantId = c.Int(nullable: false),
                        ClassroomName = c.String(nullable: false, maxLength: 50, storeType: "nvarchar"),
                        Galleryful = c.Int(nullable: false),
                        Remark = c.String(maxLength: 500, storeType: "nvarchar"),
                        IsDeleted = c.Boolean(nullable: false),
                        DeleterUserId = c.Long(),
                        DeletionTime = c.DateTime(precision: 0),
                        LastModificationTime = c.DateTime(precision: 0),
                        LastModifierUserId = c.Long(),
                        CreationTime = c.DateTime(nullable: false, precision: 0),
                        CreatorUserId = c.Long(),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_ClassroomEntity_MustHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                    { "DynamicFilter_ClassroomEntity_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.Basic_CodeGroups",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        CodeGroupName = c.String(nullable: false, maxLength: 50, storeType: "nvarchar"),
                        CodeGroupKey = c.String(nullable: false, maxLength: 50, storeType: "nvarchar"),
                        SortIndex = c.Int(nullable: false),
                        IsDeleted = c.Boolean(nullable: false),
                        DeleterUserId = c.Long(),
                        DeletionTime = c.DateTime(precision: 0),
                        LastModificationTime = c.DateTime(precision: 0),
                        LastModifierUserId = c.Long(),
                        CreationTime = c.DateTime(nullable: false, precision: 0),
                        CreatorUserId = c.Long(),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_CodeGroupEntity_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.Basic_Codes",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        CodeName = c.String(nullable: false, maxLength: 50, storeType: "nvarchar"),
                        CodeKey = c.String(nullable: false, maxLength: 50, storeType: "nvarchar"),
                        SortIndex = c.Int(nullable: false),
                        CodeGroupID = c.Guid(nullable: false),
                        IsDeleted = c.Boolean(nullable: false),
                        DeleterUserId = c.Long(),
                        DeletionTime = c.DateTime(precision: 0),
                        LastModificationTime = c.DateTime(precision: 0),
                        LastModifierUserId = c.Long(),
                        CreationTime = c.DateTime(nullable: false, precision: 0),
                        CreatorUserId = c.Long(),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_CodeEntity_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Basic_CodeGroups", t => t.CodeGroupID, cascadeDelete: true)
                .Index(t => t.CodeGroupID);
            
            CreateTable(
                "dbo.Edu_Courses",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        TenantId = c.Int(nullable: false),
                        CourseName = c.String(nullable: false, maxLength: 50, storeType: "nvarchar"),
                        IsAutoCreateName = c.Boolean(nullable: false),
                        Years = c.Int(nullable: false),
                        Period = c.String(maxLength: 20, storeType: "nvarchar"),
                        PeriodGUID = c.Guid(),
                        Grade = c.String(maxLength: 50, storeType: "nvarchar"),
                        GradeGUID = c.Guid(),
                        Subject = c.String(maxLength: 50, storeType: "nvarchar"),
                        SubjectGUID = c.Guid(),
                        SubjectType = c.String(maxLength: 50, storeType: "nvarchar"),
                        SubjectTypeGUID = c.Guid(),
                        IsQK = c.Boolean(nullable: false),
                        ChargeType = c.String(maxLength: 50, storeType: "nvarchar"),
                        IsAnQi = c.Boolean(nullable: false),
                        ChargeTime = c.Int(nullable: false),
                        Price = c.Decimal(nullable: false, precision: 10, scale: 2),
                        CourseType = c.String(maxLength: 50, storeType: "nvarchar"),
                        CourseTypeGuid = c.Guid(),
                        IsDisable = c.Boolean(nullable: false),
                        Remark = c.String(maxLength: 500, storeType: "nvarchar"),
                        IsDeleted = c.Boolean(nullable: false),
                        DeleterUserId = c.Long(),
                        DeletionTime = c.DateTime(precision: 0),
                        LastModificationTime = c.DateTime(precision: 0),
                        LastModifierUserId = c.Long(),
                        CreationTime = c.DateTime(nullable: false, precision: 0),
                        CreatorUserId = c.Long(),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_CourseEntity_MustHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                    { "DynamicFilter_CourseEntity_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.Edu_CourseSchedules",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        Chapter = c.String(nullable: false, maxLength: 20, storeType: "nvarchar"),
                        Content = c.String(maxLength: 100, storeType: "nvarchar"),
                        CourseID = c.Guid(nullable: false),
                        IsDeleted = c.Boolean(nullable: false),
                        DeleterUserId = c.Long(),
                        DeletionTime = c.DateTime(precision: 0),
                        LastModificationTime = c.DateTime(precision: 0),
                        LastModifierUserId = c.Long(),
                        CreationTime = c.DateTime(nullable: false, precision: 0),
                        CreatorUserId = c.Long(),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_CourseScheduleEntity_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Edu_Courses", t => t.CourseID, cascadeDelete: true)
                .Index(t => t.CourseID);
            
            CreateTable(
                "dbo.PSS_ItemCategorys",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        TenantId = c.Int(nullable: false),
                        ItemCategoryName = c.String(nullable: false, maxLength: 50, storeType: "nvarchar"),
                        Remark = c.String(maxLength: 200, storeType: "nvarchar"),
                        IsDeleted = c.Boolean(nullable: false),
                        DeleterUserId = c.Long(),
                        DeletionTime = c.DateTime(precision: 0),
                        LastModificationTime = c.DateTime(precision: 0),
                        LastModifierUserId = c.Long(),
                        CreationTime = c.DateTime(nullable: false, precision: 0),
                        CreatorUserId = c.Long(),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_ItemCategory_MustHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                    { "DynamicFilter_ItemCategory_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.PSS_ItemDetails",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        ItemName = c.String(nullable: false, maxLength: 50, storeType: "nvarchar"),
                        ItemCode = c.String(maxLength: 50, storeType: "nvarchar"),
                        Specification = c.String(maxLength: 50, storeType: "nvarchar"),
                        PurchasePrice = c.Decimal(nullable: false, precision: 10, scale: 2),
                        SalePrice = c.Decimal(nullable: false, precision: 10, scale: 2),
                        Units = c.String(maxLength: 20, storeType: "nvarchar"),
                        Remark = c.String(maxLength: 200, storeType: "nvarchar"),
                        ItemCategoryId = c.Guid(nullable: false),
                        IsDeleted = c.Boolean(nullable: false),
                        DeleterUserId = c.Long(),
                        DeletionTime = c.DateTime(precision: 0),
                        LastModificationTime = c.DateTime(precision: 0),
                        LastModifierUserId = c.Long(),
                        CreationTime = c.DateTime(nullable: false, precision: 0),
                        CreatorUserId = c.Long(),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_ItemDetail_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.PSS_ItemCategorys", t => t.ItemCategoryId, cascadeDelete: true)
                .Index(t => t.ItemCategoryId);
            
            CreateTable(
                "dbo.Stu_StudentOrderItems",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        StudentOrderId = c.Guid(nullable: false),
                        ItemName = c.String(maxLength: 50, storeType: "nvarchar"),
                        Price = c.Decimal(nullable: false, precision: 10, scale: 2),
                        Number = c.Int(nullable: false),
                        Units = c.String(maxLength: 20, storeType: "nvarchar"),
                        Discount = c.Int(nullable: false),
                        DiscountPrice = c.Decimal(nullable: false, precision: 10, scale: 2),
                        Amount = c.Decimal(nullable: false, precision: 10, scale: 2),
                        GiveNumber = c.Int(nullable: false),
                        IsShare = c.Boolean(nullable: false),
                        IsDeleted = c.Boolean(nullable: false),
                        DeleterUserId = c.Long(),
                        DeletionTime = c.DateTime(precision: 0),
                        LastModificationTime = c.DateTime(precision: 0),
                        LastModifierUserId = c.Long(),
                        CreationTime = c.DateTime(nullable: false, precision: 0),
                        CreatorUserId = c.Long(),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_StudentOrderItem_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Stu_StudentOrders", t => t.StudentOrderId, cascadeDelete: true)
                .Index(t => t.StudentOrderId);
            
            CreateTable(
                "dbo.Stu_StudentOrders",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        TenantId = c.Int(nullable: false),
                        OrderCode = c.String(maxLength: 50, storeType: "nvarchar"),
                        SName = c.String(nullable: false, maxLength: 50, storeType: "nvarchar"),
                        MobileNo = c.String(nullable: false, maxLength: 50, storeType: "nvarchar"),
                        Sex = c.Int(nullable: false),
                        Account = c.String(nullable: false, maxLength: 50, storeType: "nvarchar"),
                        OrderDate = c.DateTime(nullable: false, precision: 0),
                        OrderStatus = c.String(maxLength: 50, storeType: "nvarchar"),
                        EName = c.String(maxLength: 50, storeType: "nvarchar"),
                        FullTimeSchoolId = c.Guid(),
                        GradeId = c.Guid(),
                        MotherName = c.String(maxLength: 50, storeType: "nvarchar"),
                        MotherMobileNo = c.String(maxLength: 50, storeType: "nvarchar"),
                        MotherJob = c.String(maxLength: 50, storeType: "nvarchar"),
                        FatherName = c.String(maxLength: 50, storeType: "nvarchar"),
                        FatherMobileNo = c.String(maxLength: 50, storeType: "nvarchar"),
                        FatherJob = c.String(maxLength: 50, storeType: "nvarchar"),
                        ClassId = c.Guid(),
                        Birthday = c.DateTime(nullable: false, precision: 0),
                        CID = c.String(maxLength: 18, storeType: "nvarchar"),
                        Address = c.String(maxLength: 100, storeType: "nvarchar"),
                        IsDeleted = c.Boolean(nullable: false),
                        DeleterUserId = c.Long(),
                        DeletionTime = c.DateTime(precision: 0),
                        LastModificationTime = c.DateTime(precision: 0),
                        LastModifierUserId = c.Long(),
                        CreationTime = c.DateTime(nullable: false, precision: 0),
                        CreatorUserId = c.Long(),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_StudentOrder_MustHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                    { "DynamicFilter_StudentOrder_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.View_Courses",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        CourseId = c.Guid(nullable: false),
                        CourseName = c.String(maxLength: 50, storeType: "nvarchar"),
                        Price = c.Decimal(nullable: false, precision: 10, scale: 2),
                        CodeName = c.String(maxLength: 50, storeType: "nvarchar"),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.PSS_Warehouses",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        TenantId = c.Int(nullable: false),
                        WarehouseName = c.String(nullable: false, maxLength: 50, storeType: "nvarchar"),
                        WarehouseCode = c.String(maxLength: 50, storeType: "nvarchar"),
                        WarehouseType = c.Int(nullable: false),
                        Remark = c.String(maxLength: 500, storeType: "nvarchar"),
                        IsDeleted = c.Boolean(nullable: false),
                        DeleterUserId = c.Long(),
                        DeletionTime = c.DateTime(precision: 0),
                        LastModificationTime = c.DateTime(precision: 0),
                        LastModifierUserId = c.Long(),
                        CreationTime = c.DateTime(nullable: false, precision: 0),
                        CreatorUserId = c.Long(),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_Warehouse_MustHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                    { "DynamicFilter_Warehouse_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.Stu_StudentOrderItems", "StudentOrderId", "dbo.Stu_StudentOrders");
            DropForeignKey("dbo.PSS_ItemDetails", "ItemCategoryId", "dbo.PSS_ItemCategorys");
            DropForeignKey("dbo.Edu_CourseSchedules", "CourseID", "dbo.Edu_Courses");
            DropForeignKey("dbo.Basic_Codes", "CodeGroupID", "dbo.Basic_CodeGroups");
            DropIndex("dbo.Stu_StudentOrderItems", new[] { "StudentOrderId" });
            DropIndex("dbo.PSS_ItemDetails", new[] { "ItemCategoryId" });
            DropIndex("dbo.Edu_CourseSchedules", new[] { "CourseID" });
            DropIndex("dbo.Basic_Codes", new[] { "CodeGroupID" });
            DropTable("dbo.PSS_Warehouses",
                removedAnnotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_Warehouse_MustHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                    { "DynamicFilter_Warehouse_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                });
            DropTable("dbo.View_Courses");
            DropTable("dbo.Stu_StudentOrders",
                removedAnnotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_StudentOrder_MustHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                    { "DynamicFilter_StudentOrder_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                });
            DropTable("dbo.Stu_StudentOrderItems",
                removedAnnotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_StudentOrderItem_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                });
            DropTable("dbo.PSS_ItemDetails",
                removedAnnotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_ItemDetail_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                });
            DropTable("dbo.PSS_ItemCategorys",
                removedAnnotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_ItemCategory_MustHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                    { "DynamicFilter_ItemCategory_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                });
            DropTable("dbo.Edu_CourseSchedules",
                removedAnnotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_CourseScheduleEntity_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                });
            DropTable("dbo.Edu_Courses",
                removedAnnotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_CourseEntity_MustHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                    { "DynamicFilter_CourseEntity_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                });
            DropTable("dbo.Basic_Codes",
                removedAnnotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_CodeEntity_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                });
            DropTable("dbo.Basic_CodeGroups",
                removedAnnotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_CodeGroupEntity_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                });
            DropTable("dbo.Basic_Classrooms",
                removedAnnotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_ClassroomEntity_MustHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                    { "DynamicFilter_ClassroomEntity_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                });
        }
    }
}
